package kr.hkit.coffeemgn.DTO;

import java.text.DecimalFormat;

import kr.hkit.framework.util.MathUtil;

public class CoffeeDTO {
	private String pCode;
	private String pName;
	private int pCost;
	private int pCnt;
	private int pRate;

	public CoffeeDTO() {
	}

	public CoffeeDTO(String pCode, String pName, int pCost, int pCnt, int pRate) {
		this.pCode = pCode;
		this.pName = pName;
		this.pCost = pCost;
		this.pCnt = pCnt;
		this.pRate = pRate;
	}

	/**
	 * 판매금액
	 * 
	 * @return
	 */
	public int calSaleCost() {
		return pCost * pCnt;
	}

	/**
	 * 부가세액
	 * 
	 * @return
	 */
	public int calAddTax() {
		double tax = calSaleCost() / 11.0;
		
		return (int) Math.ceil(MathUtil.getDecimalPosition(tax, 1));
	}
	
	public int calPushCost(){
		return calSaleCost() - calAddTax();
	}
	
	public int calRateCost(){
		return (int) Math.round(MathUtil.getDecimalPosition(calPushCost() * pRate/100.0,1));
	}

	public static void main(String[] args) {
		CoffeeDTO coffee = new CoffeeDTO("aaaa", "aaa", 5200, 250, 12);
		System.out.println(coffee);
	}

	public String getpCode() {
		return pCode;
	}

	public void setpCode(String pCode) {
		this.pCode = pCode;
	}

	public String getpName() {
		return pName;
	}

	public void setpName(String pName) {
		this.pName = pName;
	}

	public int getpCost() {
		return pCost;
	}

	public void setpCost(int pCost) {
		this.pCost = pCost;
	}

	public int getpCnt() {
		return pCnt;
	}

	public void setpCnt(int pCnt) {
		this.pCnt = pCnt;
	}

	public int getpRate() {
		return pRate;
	}

	public void setpRate(int pRate) {
		this.pRate = pRate;
	}

	@Override
	public String toString() {
		return String
				.format("CoffeeDTO [pCode=%s, pName=%s, pCost=%s, pCnt=%s, pRate=%s, calSaleCost()=%s, calAddTax()=%s, calPushCost()=%s, calRateCost()=%s]",
						pCode, pName, pCost, pCnt, pRate, calSaleCost(),
						calAddTax(), calPushCost(), calRateCost());
	}

}
